package com.rabbit.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rabbit.vo.req.LoginLogReq;
import com.rabbit.vo.res.LoginLogRes;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import com.rabbit.mapper.LoginLogMapper;
import com.rabbit.service.LoginLogService;
import org.springframework.transaction.annotation.Transactional;

/**
 * <h1>登录日志业务实现类</h1>
 *
 * @author zjw
 * @date 2022/1/21 22:15
 */
@Service
public class LoginLogServiceImpl implements LoginLogService {

    @Resource
    private LoginLogMapper loginLogMapper;

    @Override
    public PageInfo<LoginLogRes> queryLoginLogList(LoginLogReq loginLogReq) {
        return PageHelper.startPage(loginLogReq.getPage(), loginLogReq.getLimit())
                .doSelectPageInfo(() -> loginLogMapper.queryLoginLogList(loginLogReq));
    }

    @Override
    public void truncateLoginLog() {
        loginLogMapper.truncateLoginLog();
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer batchDelete(LoginLogReq loginLogReq) {
        return loginLogMapper.batchDelete(loginLogReq.getLoginIds());
    }
}
